package com.tnovoselec.android.memory.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.Toast;

import com.tnovoselec.android.memory.R;
import com.tnovoselec.android.memory.activity.SingleGameActivity;

public class HomeFragment extends Fragment implements OnClickListener{
	
	private Button singleGame;
	private Button multiGame;
	private Button highscores;
	private Button settings;
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		View v = inflater.inflate(R.layout.fragment_dashboard, container, false);
		singleGame = (Button)v.findViewById(R.id.home_btn_single);
		multiGame = (Button)v.findViewById(R.id.home_btn_multi);
		highscores = (Button)v.findViewById(R.id.home_btn_highscores);
		settings = (Button)v.findViewById(R.id.home_btn_settings);
		
		singleGame.setOnClickListener(this);
		multiGame.setOnClickListener(this);
		highscores.setOnClickListener(this);
		settings.setOnClickListener(this);
		return v;
	}

	@Override
	public void onClick(View v) {
		Intent i = null;
		if (v == singleGame){
			i = new Intent(getActivity(), SingleGameActivity.class);
		} else if (v == multiGame){
			Toast.makeText(getActivity(), "Not yet implemented!", Toast.LENGTH_SHORT).show();
		} else if (v == highscores){
			Toast.makeText(getActivity(), "Not yet implemented!", Toast.LENGTH_SHORT).show();
		} else if (v == settings){
			Toast.makeText(getActivity(), "Not yet implemented!", Toast.LENGTH_SHORT).show();
		}
		
		if (i!= null){
			startActivity(i);
		}
		
	}

}
